package com.free.semantic.infrastruct.mapper;

import com.free.semantic.infrastruct.common.ConceptObjectDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ConceptObjectMapper {
    
    @Select("SELECT * FROM concept_object WHERE id = #{id}")
    ConceptObjectDO findById(@Param("id") Long id);
    
    @Select("SELECT * FROM concept_object WHERE semantic_network_id = #{semanticNetworkId}")
    List<ConceptObjectDO> findBySemanticNetworkId(@Param("semanticNetworkId") Long semanticNetworkId);
    
    @Insert("INSERT INTO concept_object(name, semantic_network_id, create_time, update_time) " +
            "VALUES(#{name}, #{semanticNetworkId}, NOW(), NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(ConceptObjectDO conceptObjectDO);
    
    @Update("UPDATE concept_object SET name = #{name}, update_time = NOW() WHERE id = #{id}")
    int update(ConceptObjectDO conceptObjectDO);
    
    @Delete("DELETE FROM concept_object WHERE id = #{id}")
    int deleteById(@Param("id") Long id);


    @Delete("DELETE FROM concept_object WHERE semantic_network_id = #{id}")
    int deleteBySemanticNetworkId(@Param("id") Long id);
} 